﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Home.Haushalt.Lib;
using Infragistics.Win.UltraWinGrid;
using Home.Haushalt.Lib.Element;

namespace Home.Haushalt.Gui
{
    /// <summary>
    /// 
    /// </summary>
    public partial class FrmPropertyDate : FrmProperty
    {
        /// <summary>
        /// 
        /// </summary>
        public FrmPropertyDate()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmPropertyDate_Load(object sender, EventArgs e)
        {
                ElementObject.OnAcceptChanges += new EventHandler<HEventArgs>(_elementObject_OnAcceptChanges);

            lblTermin.Enabled = lblTerminValue.Enabled = ElementObject.Row[Date.Fields.IsFree].ToBool(true);

            AddBinding(txtName.DataBindings, "Text", Date.Fields.Name);
            AddBinding(txtSum.DataBindings, "Text", Date.Fields.Summe);
            AddBinding(lblTerminValue.DataBindings, "Text", Date.Fields.Termin);

            lstSaldotype.AddBinding(_elementObject, Date.Fields.SaldotypId);
            lstOpponent.AddBinding(_elementObject, Date.Fields.OpponentId);
            lstPosten.AddBinding(_elementObject, Date.Fields.PostenId);
            lstGroup.AddBinding(_elementObject, Date.Fields.GroupId);

            AddBinding(cbActive.DataBindings, "Checked", Date.Fields.Active);

            AddBinding(calDate.DataBindings, "Value", Date.Fields.Posting);

            DataBind();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _elementObject_OnAcceptChanges(object sender, HEventArgs e)
        {
            WindowController.RefreshMonthbalanceGrids();

            SetAppState();
        }


    }
}
